﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>toggleClass()方法</title>
    <script>
        $(document).ready(function () {
            $("button").click(function () {
                $("p").toggleClass("main");
            });
        });
    </script>
    <style>
        .main {
            font-size: 20px;
            color: red;
        }
    </style>
</head>
<body>
    <p>旧时王谢堂前燕，</p>
    <p class="main">飞入寻常百姓家。</p>
    <button>转换P元素的"main"类</button>
</body>
</html>